package com.wgchao.identityrightsmanagement.infrastructure.convert;

import com.wgchao.identityrightsmanagement.domain.resource.model.FunctionResources;
import com.wgchao.identityrightsmanagement.domain.resource.model.MenuResources;
import com.wgchao.identityrightsmanagement.infrastructure.jpa.entity.SysResourceFunction;
import com.wgchao.identityrightsmanagement.infrastructure.jpa.entity.SysResourceMenu;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName: FunctionConvert
 * @author: wgchao
 * @createTime: 2020/6/18 3:19 PM
 * @Description: TODO
 */
@Component
public class FunctionConvert {

    public FunctionResources convert(SysResourceFunction sysResourceFunction){
        return new FunctionResources(sysResourceFunction.getId(), sysResourceFunction.getMenuMark(),
                sysResourceFunction.getFuncMark(), sysResourceFunction.getFuncName(), sysResourceFunction.getVersion());
    }

    public SysResourceFunction convert(FunctionResources functionResources){
        SysResourceFunction sysResourceFunction = new SysResourceFunction();
        BeanUtils.copyProperties(functionResources, sysResourceFunction);
        sysResourceFunction.setFuncMark(functionResources.getIdentify().getFuncMark());
        sysResourceFunction.setMenuMark(functionResources.getIdentify().getMenuMark());
        return sysResourceFunction;
    }
}
